package com.example.dellpc.myapplication;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import org.w3c.dom.Text;

import java.util.List;

/**
 * Created by 刘智强 on 2016/8/16.
 */
public class QuickLocationBarAdapter extends BaseAdapter {

    private Context context;
    private List<String> datas;


    public QuickLocationBarAdapter(Context context, List<String> datas) {
        this.context = context;
        this.datas = datas;
    }

    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public Object getItem(int position) {
        return datas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        VH vh = null;
        if (convertView == null) {
            vh=new VH();
            convertView = LayoutInflater.from(context).inflate(R.layout.quicklocationlistview_item, parent, false);
            vh.tv_title= (TextView) convertView.findViewById(R.id.tv_title);
            vh.tv_item= (TextView) convertView.findViewById(R.id.tv_item);
            convertView.setTag(vh);
        }else {
            vh= (VH) convertView.getTag();
        }

        vh.tv_item.setText(datas.get(position));
        return convertView;
    }

    public class VH {
        private TextView tv_title;
        private TextView tv_item;

    }
}
